// pages/work-order/index/index.ts
const app = getApp()
Page({
  data: {
    statusBarHeight: 0,
    navBarHeight: 0,
    topBg: app.getImgUrl('workOrder.webp'),
    cateList: [
      { id: 0, name: '执行中', value: 10 },
      { id: 1, name: '未指派', value: 1 },
      { id: 2, name: '超时单', value: 2 },
      { id: 3, name: '已完成', value: 1 },
      { id: 4, name: '待办', value: 5 },
    ],
    cateActiveIndex: 0,
    orderList: [
      {
        date: "2025年3月7日星期五",
        address: "西昌西路11号大厦35号",
        distance: "3.3KM",
        remainingTime: "3天",
        departureTime: "10:00前",
        type: "故障维修",
        shortType: "故障",
        description: "故障：设备检测到交换机与xx通讯提……",
        creator: "陈灵云",
        executor: "奕享 189-1088-9999",
        steps: ["已出发", "开始处理", "维修报价", "已完结"],
        currentStep: 3,
        dayName: '今天',
        iconList: ['icon-yinliang1', 'icon-play-filled', 'icon-image-fill', 'icon-qubiezhen']
      },
      {
        date: "2025年3月6日星期四",
        address: "西昌西路11号大厦35号",
        distance: "3.3KM",
        remainingTime: "3天",
        departureTime: "10:00前",
        type: "合同签订",
        shortType: "合同",
        description: "内涵：与xx乙方签订xxx合同...",
        creator: "陈灵云",
        executor: "奕享 189-1088-9999",
        steps: ["已出发", "开始处理", "合同签订", "已完结"],
        dayName: '昨天',
        currentStep: 2,
        iconList: ['icon-qubiezhen']
      },
      {
        date: "2025年3月5日星期三",
        address: "西昌西路11号大厦35号",
        distance: "3.3KM",
        remainingTime: "3天",
        departureTime: "10:00前",
        type: "其他问题",
        shortType: "其他",
        description: "描述：视频播放出现问题……",
        creator: "陈灵云",
        executor: "奕享 189-1088-9999",
        steps: ["已出发", "开始处理", "维修报价", "已完结"],
        currentStep: 4,
        iconList: ['icon-play-filled', 'icon-image-fill']
      },
      {
        date: "2025年3月5日星期三",
        address: "西昌西路11号大厦35号",
        distance: "3.3KM",
        remainingTime: "3天",
        departureTime: "10:00前",
        type: "客户保修",
        shortType: "客户",
        description: "问题：由客户提出视频播放出现问题……",
        creator: "陈灵云",
        executor: "奕享 189-1088-9999",
        steps: ["已出发", "开始处理", "维修报价", "已完结"],
        currentStep: 1,
        iconList: ['icon-yinliang1', 'icon-qubiezhen']
      }
    ]
  },
  onLoad() {
    // 同步获取窗口信息
    const windowInfo = wx.getWindowInfo();
    const statusBarHeight = windowInfo.statusBarHeight;
    const navBarHeight = statusBarHeight + 44;
    this.setData({ statusBarHeight, navBarHeight });
  },
  switchCateActive(e) {
    const id = e.currentTarget.dataset.id; // 获取点击项的id
    this.setData({
      cateActiveIndex: id // 更新激活索引
    });
    // 可选：根据业务需求加载对应分类数据
    this.loadData(id);
  },
  loadData(cateId) {
    // 根据分类id请求接口数据（示例逻辑）
    console.log('加载分类ID为', cateId, '的数据');
  },
  navigateTo(e) {
    app.navigateTo(e.currentTarget.dataset.url, e.currentTarget.dataset.type)
  }
})